{% extends 'base.html' %}

{% block content %}
<div class="container mt-4">
    <div class="card">
        <div class="card-header">
            <h4>{{ title }}</h4>
        </div>
        <div class="card-body">
            <form method="post">
                {% csrf_token %}
                {% if form.non_field_errors %}
                <div class="alert alert-danger">
                    {% for error in form.non_field_errors %}
                    {{ error }}
                    {% endfor %}
                </div>
                {% endif %}

                <div class="mb-3">
                    <label for="{{ form.chapter.id_for_label }}" class="form-label">{{ form.chapter.label }}</label>
                    {{ form.chapter }}
                    {% if form.chapter.errors %}
                    <div class="text-danger">
                        {{ form.chapter.errors }}
                    </div>
                    {% endif %}
                </div>

                <div class="mb-3">
                    <label for="{{ form.name.id_for_label }}" class="form-label">{{ form.name.label }}</label>
                    {{ form.name }}
                    {% if form.name.errors %}
                    <div class="text-danger">
                        {{ form.name.errors }}
                    </div>
                    {% endif %}
                </div>

                <div class="mb-3">
                    <label for="{{ form.description.id_for_label }}" class="form-label">{{ form.description.label }}</label>
                    {{ form.description }}
                    {% if form.description.errors %}
                    <div class="text-danger">
                        {{ form.description.errors }}
                    </div>
                    {% endif %}
                </div>

                <div class="mb-3">
                    <label for="{{ form.order.id_for_label }}" class="form-label">{{ form.order.label }}</label>
                    {{ form.order }}
                    {% if form.order.errors %}
                    <div class="text-danger">
                        {{ form.order.errors }}
                    </div>
                    {% endif %}
                </div>

                <div class="d-flex gap-2">
                    <button type="submit" class="btn btn-primary">保存</button>
                    
                    <a href="{% url 'core:subject_chapter_knowledge' CURRENT_SUBJECT_ID %}" class="btn btn-outline-secondary">取消</a>
                   
                </div>
            </form>
        </div>
    </div>
</div>
{% endblock %}